package com.example.springboot.biz;

import com.example.springboot.bean.Adve;
import com.example.springboot.mapper.AdveMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AdveBiz {
    @Resource
    AdveMapper am;

    // 每30秒更新定时广告状态
    @Scheduled(cron = "* * 0/3 * * ?")
    public void autoUpdateAdveStatus() {
        am.updateAdveStatus();
    }

    // 查询计量广告
    public Adve queryNumsAdve(int id) {
        Adve a = am.selectById(id);
        // 点击数 + 1
        am.updateNumsAdve(id);
        return a;
    }


}
